from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField

class Blog(models.Model):
	title = models.CharField(max_length = 20)
	author = models.ForeignKey('blog_auth.User',on_delete=models.CASCADE)
	thumbnail = models.FileField()
	content = RichTextUploadingField()
	pub_time = models.DateTimeField(auto_now_add=True)
	category = models.ForeignKey('Category',on_delete=models.SET_NULL,null=True)
	desc = models.CharField(max_length=100,default='')

	class Mete:
		ordering = ['-pub_time']


class Comment(models.Model):
	comment = models.CharField(max_length=50)
	blog = models.ForeignKey('Blog',on_delete=models.CASCADE)
	author = models.ForeignKey('blog_auth.User',on_delete=models.CASCADE)
	pub_time = models.DateTimeField(auto_now_add=True)

	class Mete:
		ordering = ['-pub_time']


class Category(models.Model):
	name = models.CharField(max_length=20)
	desc = models.CharField(max_length=100)
	author = models.ForeignKey('blog_auth.User',on_delete=models.CASCADE)

class Home_Info(models.Model):
	thumbnail = models.FileField()
	desc = models.TextField()
